package com.synjones.handsetS8.ild.adapter;

import android.content.Context;
import android.view.View;

import com.synjones.handsetS8.R;;
import com.synjones.handsetS8.ild.adapter.viewholder.WorkerRvViewHolder;
import com.synjones.handsetS8.ild.base.BaseRecyclerAdapter;
import com.synjones.handsetS8.ild.net.model.WorkerResult;

import java.util.List;

/**
 * @author Chris Chan
 * Create on: 2021/7/15}11:49
 * For:
 * Explain:
 */
public class WorkerRvAdapter extends BaseRecyclerAdapter<WorkerResult, WorkerRvViewHolder> {
    private OnItemChildViewClickListener<WorkerResult> onItemChildViewClickListener;

    public WorkerRvAdapter(Context context) {
        super(context);
    }

    public WorkerRvAdapter(Context context, List<WorkerResult> dataList) {
        super(context, dataList);
    }

    @Override
    protected int layoutId() {
        return R.layout.item_worker;
    }

    @Override
    protected WorkerRvViewHolder createViewHolder(View itemView) {
        WorkerRvViewHolder workerRvViewHolder = new WorkerRvViewHolder(context, itemView);
        if (null != this.onItemChildViewClickListener) {
            workerRvViewHolder.setOnItemChildViewClickListener(this.onItemChildViewClickListener);
        }
        return workerRvViewHolder;
    }

    @Override
    protected void refreshItemView(WorkerRvViewHolder holder, WorkerResult item) {
        holder.refreshView(item);
    }

    public void setOnItemChildViewClickListener(OnItemChildViewClickListener<WorkerResult> onItemChildViewClickListener) {
        this.onItemChildViewClickListener = onItemChildViewClickListener;
    }
}
